<template>
  <div class="dashboard-editor-container">
    <h2>欢迎登陆淘卡后台管理系统</h2>
    <h4>欢迎{{userName}}，上次登录系统时间：{{lastLoginTime}}</h4>
    <h5>用户数量:{{userCount}}   发布的车辆:{{truckCount}}</h5>
  </div>
</template>

<script>
    import { mapGetters } from 'vuex'
    export default {
        name: 'DashboardAdmin',
        data() {
            return {
                userName:'',
                truckCount:0,
                userCount:0,
                lastLoginTime:''
            }
        },
        methods: {
            loadIndexData(){
                this.$api.loadIndexData().then(d => {
                    let result = d.data;
                    if (result.code !== 0) {
                        this.$alert(result.msg);
                        return;
                    }
                     d = result.data;
                    this.userName=d.userName;
                    this.truckCount = d.truckCount;
                    this.userCount = d.userCount;
                    this.lastLoginTime = d.lastLoginTime;
                });
            }
        },
        created(){
            this.loadIndexData();
        }
    }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .dashboard-editor-container {
    padding: 32px;
    background-color: rgb(240, 242, 245);
  }
</style>
